package com.momo.background.service.impl;

import com.momo.background.dao.mapping.EXT.HotelUserMapperExt;
import com.momo.background.dao.mapping.UserInfoMapper;
import com.momo.background.dto.UserInfoDto;
import com.momo.background.service.UserService;
import com.momo.background.vo.AdminVo;
import com.momo.background.vo.UserVo;
import com.momo.hotel.dao.pojo.TbUser;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserserviceImpl implements UserService {

    @Resource
    UserInfoMapper userMapper;

    @Resource
    HotelUserMapperExt hotelUserMapperExt;

    @Override
    public AdminVo  AdminLogin(AdminVo adminVo) {
        return hotelUserMapperExt.AdminLogin(adminVo);
    }

    @Override
    public List<UserInfoDto> ListAll(UserInfoDto userInfoDto) {
        return userMapper.ListAll(userInfoDto);
    }

    @Override
    public Integer userRegister(AdminVo adminVo) {
        return hotelUserMapperExt.insertext(adminVo);
    }

    @Override
    public AdminVo hotelPhoneCheck(String phone) {
        return hotelUserMapperExt.hotelPhoneCheck(phone);
    }

    @Override
    public AdminVo hotelUserNameCheck(String username) {
        return hotelUserMapperExt.hotelUserNameCheck(username);
    }

    @Override
    public List<TbUser> SelectUserByID(Integer id) {
        return userMapper.SelectUserByID(id);
    }

    @Override
    public Boolean updateUserInfoById(UserVo userVo) {
        Integer integer = userMapper.updateUserInfoById(userVo);
        if(integer>0){
            return true;
        }
        return false;
    }


    @Override
    public int hotelUserDel(String id) {
        return hotelUserMapperExt.hotelUserDel(id);
    }

    @Override
    public int hotelUserDelByIds(String[] id) {
        int rSet=0;
        for (int i=0;i<id.length;i++){
            hotelUserMapperExt.hotelUserDel(id[i]);
            rSet++;
        }
        return rSet;
    }
}
